package 题目集.hash;

import java.util.Scanner;

public class 水题 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        char[] chars = sc.nextLine().toCharArray();
        int[] count=new int[26];
        for (char c : chars) {
            count[c-'a']++;
        }
        int max=0;
        int min=Integer.MAX_VALUE;
        for (int i = 0; i < count.length; i++) {
            if (count[i]!=0){
                max=Math.max(max,count[i]);
                min=Math.min(min,count[i]);
            }
        }
        System.out.println(max-min);
    }
}
